<template>
  <!-- 审核-->
  <a-modal :width="500" v-model:visible="showAuditDialog" title="审核" title-align="start" :mask-closable="false" @cancel="closedDialog" :on-before-ok="submitAudit">
    <a-radio-group v-model="state">
      <a-radio :value="true">通过</a-radio>
      <a-radio :value="false">驳回</a-radio>
    </a-radio-group>
    <div v-if="!state">
      <p style="margin: 20px 0 10px; color: #999">
        <span class="warningColor">*</span>
        <span>注：驳回必须填写驳回原因</span>
      </p>
      <a-textarea v-model="result" style="height: 100px" placeholder="请填写驳回原因" allow-clear />
    </div>
  </a-modal>
</template>
<script lang="ts" setup>
  import { ref } from 'vue'
  import { Message } from '@arco-design/web-vue'

  const emit = defineEmits(['closed', 'success'])
  const props = defineProps({
    isShow: {
      type: Boolean,
      default: false,
    },
  })

  const showAuditDialog = ref(props.isShow)
  const state = ref(true)
  const result = ref()

  // 选择产品
  async function submitAudit() {
    if (!state.value && !result.value) {
      Message.error('必须填写驳回原因')
      return false
    }
    emit('success', {
      state: state.value,
      result: result.value,
    })
    emit('closed')
    return true
  }
  // 关闭
  function closedDialog() {
    showAuditDialog.value = false
    emit('closed')
  }
</script>
<style lang="less" scoped></style>
